/**
 * @author: 小红
 * @date: 2025/3/26
 * @Description:
 */

import { replace } from 'lodash-es';

/**
 * 去除字符串中的斜杠
 * @param str
 * @param path
 */
export function stringRemoveSlash(str: string, path?: string): string {
	const repStr = replace(str, /\//g, '');
	return `${repStr}${path || ''}`;
}

/**
 * 处理 import glob 默认导出
 */
export function importGlobDefault(glob: any) {
	const modules: any = [];

	for (const ms of Object.values(glob)) {
		modules.push((ms as any)?.default ?? []);
	}

	return modules;
}

/**
 * 把文件转换为 formDta
 */
export function fileToFormData(file: File, fileName?: string): FormData {
	const formData = new FormData();
	formData.append(fileName || 'file', file);
	return formData;
}
